<template>
	<view class="content">
		<search :banner="banner"></search>
		<views></views>
		<viewBody></viewBody>
		<scroll :tab="tab"></scroll>
		<view style="height: 140upx;"></view>
		<!-- tab切换loading -->
		<!-- <load-list :lading="false"></load-list> -->
		<active :recomment="recomment"></active>
		<!-- 进入页面加载 -->
		<home-load v-if="homeload"></home-load>
	</view>
</template>

<script>
	import search from './comments/search.vue';
	import views from './comments/views.vue';
	import viewBody from './comments/viewBody.vue';
	import scroll from './comments/scroll.vue';
	import active from './comments/actives.vue';
	import {home,homelist} from '../../http/config.js';
	import {mapState} from 'vuex'
	
	export default {
		data() {
			return {
				banner:[],
				tab:[],
				recomment:[],
				pageid:0,
				homeload:true
			}
		},
		
		onLoad() {

		},
		
		components:{
			search,
			views,
			viewBody,
			scroll,
			active
		},
		created() {
			//请求轮播
			const banners = 'banner';
			//请求tab栏
			const tab = 'tab'
			//请求列表数据
			const recomment = 'recomment'
			Promise.all([
				home(banners),home(tab),homelist(recomment,this.pageid)
			]).then(res=>{
				this.banner = res[0].data
				this.tab = res[1].data
				this.recomment = res[2].data
				console.log(res[2].data)
				
				//进入页面loading
				this.homeload=false
			}).catch(err=>{
				console.log(err)
			})
			
		},
		
		methods: {
			//上拉加载
			// pullon(){
			// 	const recomment = 'recomment';
			// 	homelist(recomment,this.pageid)
			// 	.then(res=>{
			// 		console.log(res)
			// 		this.recomment = [...this.recomment,...res.data]
			// 	}).catch(err=>{
			// 		console.log(err)
			// 	})
			// }
		},
		//上拉加载接口
		onReachBottom() {
			// this.pageid++;
			// console.log(this.pageid);
			// this.pullon()
		},
		
		computed:{
			//取出store中的数据
			...mapState(['list']),
			//取到tab切换的数据
			countwzs(){
				this.recomment = this.list.listing
			}
		}
	}
</script>

<style lang="scss">
	page{
		// background-color: #dcdcdc;
	}
</style>
